import {defineStore} from "pinia";
import {ref} from "vue";
import type {Video, PersonalizedPrivateContent} from "@/models/video";
import {useVideoTimelineRecommend, usePersonalizedMv,usePersonalizedPrivateContentList} from "@/API/api"
import type {PersonalizedMv} from "@/models/personalized"

export const useVideoStore = defineStore('video', () => {
    const videoTimelineRecommend = ref<Video []>([]);
    const getVideoTimelineRecommend = async () => {
        if (videoTimelineRecommend.value.length) return;
        videoTimelineRecommend.value = await useVideoTimelineRecommend()
    };

    //推荐的mv
    const personalizedMv = ref<PersonalizedMv []>([]);
    const getPersonalizedMv = async () => {
        if (personalizedMv.value.length) return;
        personalizedMv.value = await usePersonalizedMv();
    };

    const personalizedPrivateContent = ref<PersonalizedPrivateContent[]>([]);

    const getPersonalizedPrivateContent = async () => {
        if (personalizedPrivateContent.value.length) return;
        personalizedPrivateContent.value = await usePersonalizedPrivateContentList(4)
    };

    return {
        videoTimelineRecommend,
        getVideoTimelineRecommend,
        personalizedMv,
        getPersonalizedMv,
        personalizedPrivateContent,
        getPersonalizedPrivateContent
    }
});
